package com.pzhu.config;

import com.pzhu.common.constant.Constant;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

/**
 * @author zengqiuhu
 * @date 2023/4/25 12:19
 */
@Configuration
public class SwaggerConfig {
    @Bean
    public Docket customDocket() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage(Constant.FORBIDDEN_BASEPKG))
                .build();
    }

    private ApiInfo apiInfo() {
        Contact contact = new Contact(Constant.SWAGGER_NAME, Constant.SWAGGER_URL, Constant.SWAGGER_EMAIL);
        return new ApiInfoBuilder()
                .title(Constant.SWAGGER_TITLE)
                .description(Constant.SWAGGER_DESC)
                .contact(contact)   // 联系方式
                .version(Constant.SWAGGER_VERSION)  // 版本
                .build();
    }
}
